package com.lk.sys.common.vo;

import java.io.Serializable;
/**
 * 封装控制层返回客户端的数据，要求这些数据必须有状态信息。
 * @author Lukang
 * @date 2021/10/26 下午8:41
 * @param
 * @return null
 */
public class JsonResult implements Serializable {

    private static final long serialVersionUID = 7926700710535633314L;
    private int state = 1;
    private String message = "ok";
    private Object data;

    public JsonResult(String message) {
        this.message = message;
    }

    public JsonResult(Object data) {
        this.data = data;
    }

    public JsonResult(Exception e) {
        this.state = 0;
        this.message = e.getMessage();
    }


    @Override
    public String toString() {
        return "JsonResult{" +
                "state=" + state +
                ", message='" + message + '\'' +
                ", data=" + data +
                '}';
    }

    public int getState() {
        return state;
    }

    public void setState(int state) {
        this.state = state;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
